package com.project.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.bean.PostBean;
import com.project.bean.UserBean;
import com.project.service.IChannelService;
import com.project.service.IPostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.time.LocalDate;

/**主贴  */
@RestController
@RequestMapping("post")
public class PostController {
    @Autowired
    private IPostService service;
    @RequestMapping("cutByItem")
    public IPage<PostBean> cutByItem(Integer pageNum, Integer id,String title, String name, LocalDate startDate, LocalDate endDate){
        return service.cutByItem(pageNum,id,title,name,startDate,endDate);
    }
    @RequestMapping("add")
    public String add(PostBean postBean, HttpServletRequest request){
        UserBean user = (UserBean) request.getSession().getAttribute("loginUser");
        postBean.setUserId(user.getId());
        service.add(postBean);
        return "ok";
    }
    @RequestMapping("findById")
    public PostBean findById(Integer id){
        return service.findById(id);
    }

}
